#!/usr/bin/env python

import wx
import resource as r

class Options(wx.Window):
    '''Options class
    
    @author Julot <andy.julot@gmail.com>
    @since Saturday, February 04, 2012. 05:05 PM'''
    
    def __init__(self, parent):
        wx.Window.__init__(self, parent, style=wx.BORDER_THEME)
        
        size = (50, -1)
        style = wx.TE_RIGHT
        
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.AddSpacer(r.value.spacer / 2)
        
        label = wx.StaticText(self, label='Preset:')
        sizer.Add(label, flag=wx.ALIGN_CENTER_VERTICAL)
        
        self.preset = wx.ComboBox(self, style=wx.CB_DROPDOWN)
        sizer.Add(self.preset)
        
        sizer.AddSpacer(r.value.spacer)
        
        self.width = _Size(self, 'Width:')
        sizer.Add(self.width)
        
        sizer.AddSpacer(r.value.spacer)
        
        self.height = _Size(self, 'Height:')
        sizer.Add(self.height)
        
        sizer.AddSpacer(r.value.spacer)
        
        label = wx.StaticText(self, label='Left Margin:')
        sizer.Add(label, flag=wx.ALIGN_CENTER_VERTICAL)
        
        self.leftMargin = wx.TextCtrl(self, size=size, style=style)
        sizer.Add(self.leftMargin)
        label = wx.StaticText(self, label=' mm.')
        sizer.Add(label, flag=wx.ALIGN_CENTER_VERTICAL)
        
        sizer.AddSpacer(r.value.spacer)
        
        self.rotated = wx.CheckBox(self, label='Rotate')
        sizer.Add(self.rotated, flag=wx.ALIGN_CENTER_VERTICAL)
        
        sizer.AddSpacer(r.value.spacer)
        
        self.bordered = wx.CheckBox(self, label='Border')
        sizer.Add(self.bordered, flag=wx.ALIGN_CENTER_VERTICAL)
        
        self.radius = wx.TextCtrl(self, size=size, style=style)
        self.radius.ToolTip = wx.ToolTip('Radius')
        sizer.Add(self.radius)
        label = wx.StaticText(self, label=' mm.')
        sizer.Add(label, flag=wx.ALIGN_CENTER_VERTICAL)
        
        self.SetSizer(sizer)
    
class _Size(wx.BoxSizer):
    def __init__(self, parent, label):
        wx.BoxSizer.__init__(self, wx.HORIZONTAL)
        
        label = wx.StaticText(parent, label=label)
        self.Add(label, flag=wx.ALIGN_CENTER_VERTICAL)
        
        size = (50, -1)
        style = wx.TE_RIGHT
        
        self._value = wx.TextCtrl(parent, size=size, style=style)
        self.Add(self._value)
        
        label = wx.StaticText(parent, label=' mm ')
        self.Add(label, flag=wx.ALIGN_CENTER_VERTICAL)
        
        self._fit = wx.CheckBox(parent, label='fit.')
        self.Add(self._fit, flag=wx.ALIGN_CENTER_VERTICAL)
    
    @property
    def value(self):
        return float(self._value.Value)
    
    @value.setter
    def value(self, value):
        self._value.Value = '%s' % value
    
    @property
    def fit(self):
        return self._fit.Value
    
    @fit.setter
    def fit(self, value):
        self._fit.Value = value
    